package thread;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Hua YY
 * Date: 2024-09-19
 * Time: 16:27
 */
public class ThreadDemon17 {
    /*
    * 使用lambda表达式和Runnable接口写法，就不能用this了
    *lambda中没有指向任何对象，this没法用
    * Runnable写法则是this指向的是Runnable
    * 所以只能用.currentThread这个方法来获取当前*/
    public static void main(String[] args) {
        Thread t1 = new Thread(()->{
            Thread t = Thread.currentThread();
            System.out.println(t.getId()+t.getName());
        });

        Thread t2 = new Thread(()->{
           Thread t = Thread.currentThread();
            System.out.println(t.getId()+t.getName());
        });
        t1.start();
        t2.start();
    }

}
